var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function h() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((h.prototype = i.prototype), new h()));
      };
    })(),
  MTPitchChargeView = (function (e) {
    function t(t) {
      var i = e.call(this) || this;
      return (
        (i.step = 1),
        i.pos(0, (Laya.stage.height - 350) / 2),
        (i.text_chage_price.restrict = "0-9"),
        (i.slider_pitchnum.changeHandler = new Handler(
          i,
          i.sliderPitchChangeFn
        )),
        i.btn_picth_add.on(Laya.Event.CLICK, i, i.onAddPlusPitchItemFn),
        i.btn_picth_dele.on(Laya.Event.CLICK, i, i.onDeletePicthItemFn),
        i.btn_charge_ok.on(Laya.Event.CLICK, i, i.onChargeOkDidClickFn),
        WebSocketService.addListener({
          caller: i,
          code: 1325,
          method: i.onLoadTianJiaWuPinDataFn,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1326,
          method: i.onLoadTianJiaWuPinDataFn,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1328,
          method: i.onLoadTianJiaWuPinDataFn,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1327,
          method: i.onLoadTianJiaWuPinDataFn,
        }),
        i
      );
    }
    return (
      __extends(t, e),
      (t.open = function (e) {
        null == this.pitchView && (this.pitchView = new t()),
          this.pitchView.popup(!0),
          (this.pitchView.picthDict = e),
          (this.pitchView.lbl_saletitle.text = "出售数量："),
          (this.pitchView.lbl_saleprice.text = "出售价格："),
          (this.pitchView.text_chage_price.text = ""),
          (this.pitchView.text_chage_price.visible = !0),
          (this.pitchView.lbl_thingprice.visible = !1),
          (this.pitchView.charge_id = e.chargeID),
          (this.pitchView.charge_type = e.chargeType),
          (this.pitchView.lbl_charge_title.text = e.chargeTitle),
          (this.pitchView.lbl_charge_sum.text = e.chargeSum),
          (this.pitchView.stone_type = e.stoneType),
          (this.pitchView.charge_count = 1),
          (this.pitchView.openType = 1);
        var i = e.chargeSum;
        i >= 100 && (i = 100),
          (this.pitchView.max = i),
          (this.pitchView.min = 1),
          (this.pitchView.step = 1),
          (this.pitchView.slider_pitchnum.max = i),
          (this.pitchView.slider_pitchnum.min = 1),
          (this.pitchView.slider_pitchnum.value = 1),
          (this.pitchView.lbl_chushouNum.text =
            this.pitchView.slider_pitchnum.value + ""),
          (this.pitchView.charge_pos = e.chargePos);
      }),
      (t.shoppingOpen = function (e) {
        null == this.pitchView && (this.pitchView = new t()),
          this.pitchView.popup(!0),
          (this.pitchView.text_chage_price.visible = !1),
          (this.pitchView.lbl_thingprice.visible = !0),
          (this.pitchView.text_chage_price.text = ""),
          (this.pitchView.lbl_charge_sum.text = e.chargeSum),
          (this.pitchView.lbl_charge_title.text = e.chargeTitle),
          e.chargeSum > 100
            ? (this.pitchView.lbl_charge_sum.text = "100")
            : (this.pitchView.lbl_charge_sum.text = e.chargeSum),
          (this.pitchView.lbl_saletitle.text = "购买数量："),
          (this.pitchView.lbl_saleprice.text = "购买价格："),
          (this.pitchView.lbl_thingprice.text = e.chargeMoney),
          (this.pitchView.picthDict = e),
          (this.pitchView.charge_pos = e.chargePos),
          (this.pitchView.charge_id = e.chargeID),
          (this.pitchView.charge_count = 1),
          (this.pitchView.charge_thingID = e.thingID),
          (this.pitchView.openType = 2);
        var i = e.chargeSum;
        i > 100 && (i = 100),
          (this.pitchView.max = i),
          (this.pitchView.min = 1),
          (this.pitchView.step = 1),
          (this.pitchView.slider_pitchnum.max = e.chargeSum),
          (this.pitchView.slider_pitchnum.min = 1),
          (this.pitchView.slider_pitchnum.value = 1),
          (this.pitchView.lbl_chushouNum.text =
            this.pitchView.slider_pitchnum.value + "");
      }),
      (t.prototype.onAddPlusPitchItemFn = function () {
        (this.charge_count = this.charge_count + this.step),
          this.charge_count > this.max && (this.charge_count = this.max),
          (this.slider_pitchnum.value = this.charge_count);
      }),
      (t.prototype.onDeletePicthItemFn = function () {
        (this.charge_count = this.charge_count - this.step),
          this.charge_count < this.min && (this.charge_count = this.min),
          (this.slider_pitchnum.value = this.charge_count);
      }),
      (t.prototype.sliderPitchChangeFn = function () {
        (this.charge_count = this.slider_pitchnum.value),
          (this.lbl_chushouNum.text = this.slider_pitchnum.value + ""),
          (this.lbl_thingprice.text =
            this.charge_count * this.picthDict.chargeMoney + "");
      }),
      (t.prototype.onChargeOkDidClickFn = function () {
        if (2 == this.openType)
          return (
            WebSocketService.send({
              c: 1329,
              d: {
                stallId: this.charge_id,
                pos: this.charge_pos,
                thingId: this.charge_thingID,
                count: this.charge_count,
              },
            }),
            void this.close()
          );
        if (this.text_chage_price.text.length <= 0)
          ToastView.toastView("请输入出摊单价");
        else {
          var e = parseFloat(this.text_chage_price.text);
          0 == this.charge_type || 3 == this.charge_type
            ? WebSocketService.send({
                c: 1325,
                d: {
                  id: this.charge_id,
                  pos: this.charge_pos,
                  count: this.charge_count,
                  money: e,
                },
              })
            : 1 == this.charge_type
            ? WebSocketService.send({
                c: 1326,
                d: { id: this.charge_id, pos: this.charge_pos, money: e },
              })
            : 2 == this.charge_type
            ? 5 == this.stone_type
              ? WebSocketService.send({
                  c: 1325,
                  d: {
                    id: this.charge_id,
                    pos: this.charge_pos,
                    count: this.charge_count,
                    money: e,
                  },
                })
              : 6 == this.stone_type
              ? WebSocketService.send({
                  c: 1327,
                  d: {
                    id: this.charge_id,
                    pos: this.charge_pos,
                    type: 1,
                    money: e,
                  },
                })
              : 9 == this.stone_type &&
                WebSocketService.send({
                  c: 1327,
                  d: {
                    id: this.charge_id,
                    pos: this.charge_pos,
                    type: 2,
                    money: e,
                  },
                })
            : 4 == this.charge_type &&
              WebSocketService.send({
                c: 1328,
                d: { id: this.charge_id, pos: this.charge_pos, money: e },
              });
        }
      }),
      (t.prototype.onLoadTianJiaWuPinDataFn = function (e) {
        0 == e.code
          ? (ToastView.toastView("添加成功"),
            WebSocketService.send({ c: 1311, d: null }),
            0 == this.charge_type &&
              WebSocketService.send({ c: 1316, d: { pageNum: 0 } }),
            1 == this.charge_type &&
              WebSocketService.send({ c: 1322, d: { pageNum: 0 } }),
            2 == this.charge_type &&
              WebSocketService.send({ c: 1323, d: { pageNum: 0 } }),
            3 == this.charge_type &&
              WebSocketService.send({ c: 1324, d: { pageNum: 0 } }),
            4 == this.charge_type &&
              WebSocketService.send({ c: 1419, d: { action: 0, pageNum: 0 } }),
            this.close(),
            Laya.stage.event("HomePageView", "close"))
          : ToastView.toastView(e.msg);
      }),
      (t.close = function () {
        this.pitchView && this.pitchView.close();
      }),
      t
    );
  })(ui.MarketController.MTPitchChargeViewUI);
